home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************************************
-
-
- Intialize Machine and all Globals
-
- written by Peter Falco, Apple Computer
-
- April, 1995
-
- *************************************************************************************************/
-
- #include <AppleEvents.h>
- #include <ToolUtils.h>
- #include <Resources.h>
- #include "QD3DtoQTVR.h"
- #include "extern.h"
- #include "inits.h"
-
- void InitializeToolbox(void)
- {
- short index ;
- long gestaltResponse;
- short numMoreMasters = 20;
-
- InitGraf(&qd.thePort);
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(0L);
- InitCursor();
- MaxApplZone();
-
-
- SetZone(ApplicZone());
- for( index = 1; index <= numMoreMasters; index++) MoreMasters();
-
-
- FlushEvents(everyEvent, 0);
-
- // Check for Drag and Drop
- if ((Gestalt(gestaltDragMgrAttr, &gestaltResponse) != noErr) ||
- (!(gestaltResponse & (1 << gestaltDragMgrPresent))))
- {
- StopAlert(512, 0L);
- ExitToShell();
- }
-
- // Check for QuickDraw 3D
- if ((Gestalt(gestaltQD3D, &gestaltResponse) != noErr) ||
- gestaltResponse == gestaltQD3DNotPresent)
- {
- StopAlert(512, 0L);
- ExitToShell();
- }
-
- // Check for QuickTime
- if (Gestalt(gestaltQuickTime, &gestaltResponse) != noErr)
- {
- StopAlert(512, 0L);
- ExitToShell();
- }
- }
-
- void InitializeGlobals(void)
- {
- gQuit = gQuitting = false;
-
- EnterMovies();
- Q3Initialize();
- }
-
-
- void DeallocateGlobals(void)
- {
- Q3Exit();
- ExitMovies();
- }
-
-
-
-
-
- void InitAEStuff( void )
- {
- OSErr err;
-
- // Set up the self-addressed descriptor record.
- pSelfPSN.highLongOfPSN = 0;
- pSelfPSN.lowLongOfPSN = kCurrentProcess; // Use this instead of GetCurrentProcess
- err = AECreateDesc(typeProcessSerialNumber,(Ptr)&pSelfPSN,sizeof(ProcessSerialNumber),&pSelfAddress);
-
- pnilDesc.descriptorType = typeNull; // Initialize the global nil descriptor record.
- pnilDesc.dataHandle = nil;
-
- RegisterMyEvents() ; // and finally register appleEvent handlers
-
- }
-
-
- Boolean SupportsAEVT(void)
- {
- OSErr err;
- long response;
-
- if (!myTrapAvailable(kGestaltTrap))
- return false;
-
- err = Gestalt(gestaltAppleEventsAttr,&response);
- if (err!=noErr)
- return false;
-
- return (response && (response << gestaltAppleEventsPresent));
- }
-
- void RegisterMyEvents(void)
- {
- OSErr err;
-
- if (!SupportsAEVT())
- return;
-
- err = AEInstallEventHandler(kCoreEventClass,kAEOpenApplication,NewAEEventHandlerProc(MyAEHandleOAPP),0L,false);
- if (err!=noErr)
- return;
-
- err = AEInstallEventHandler(kCoreEventClass,kAEOpenDocuments,NewAEEventHandlerProc(MyAEHandleODOC),0L,false);
- if (err!=noErr)
- return;
-
- err = AEInstallEventHandler(kCoreEventClass,kAEPrintDocuments,NewAEEventHandlerProc(MyAEHandlePDOC),0L,false);
- if (err!=noErr)
- return;
-
- err = AEInstallEventHandler(kCoreEventClass,kAEQuitApplication,NewAEEventHandlerProc(MyAEHandleQUIT),0L,false);
- if (err!=noErr)
- return;
-
-
- }